package com.atguigu.distributed.lock.jvm;

import java.lang.management.ManagementFactory;
import java.lang.management.MemoryPoolMXBean;

public class BigObjectTest {
    private static final int _1MB = 1024*1024;
    public static void main(String[] args) {
        byte[] allocation;
        allocation = new byte[4*_1MB];
        for(MemoryPoolMXBean memoryPoolMXBean: ManagementFactory.getMemoryPoolMXBeans()){
            System.out.println(memoryPoolMXBean.getName()+" 总量:"+memoryPoolMXBean.getUsage().getCommitted()+" 使用的内存:"+memoryPoolMXBean.getUsage().getUsed());
        }
    }
}
